#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include "../include/linked.h"
#include "../include/Hash.h"

/*Hash function*/
int hash(char *key, int tableSize)
    {
    int hashVal = 0,i;
    for(i = 0; i<strlen(key); i++)
      hashVal = 37*hashVal+key[i];
    hashVal %= tableSize;
    if(hashVal<0)
     hashVal += tableSize;
    return hashVal;
    }


void add_to_hash_table(char * key,int fdnum)
{
   int hashPos;
   hashPos=hash(key,HASH_SIZE);
   hashtABLE[hashPos]=add(hashtABLE[hashPos],key,fdnum);
   
}

void delete_from_hash_table(char * key,int fdnum)
{
   int hashPos;
   hashPos=hash(key,HASH_SIZE);
   hashtABLE[hashPos]=delete(hashtABLE[hashPos],fdnum);
   
}

int search_from_hash_table(char *key)
{
  int hashPos;
  hashPos=hash(key,HASH_SIZE);
  int fdnum=search(hashtABLE[hashPos],key);
  return fdnum;
  
  
}




 
  
